<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<link rel="stylesheet" href="__PUBLIC__/assets_reg/css/zpui.css"/>
<link rel="stylesheet" href="__PUBLIC__/assets_reg/css/all.css"/>
<script src="__PUBLIC__/assets_reg/js/page.js"></script>

    <title> 注册 </title>
    <style>
        .border-after_none:after {
            border: none!important;
        }
        .weui-label {
            width: 1rem!important;
        }
        .weui-agree__checkbox:checked:before {
            font-weight: bold;
        }
        /*-----------------------规则弹出框--------------------*/

        #guize .weui-popup__modal {
            background-color: rgba(0, 0, 0, 0.3);
        }

        #guize .weui-popup__modal .guize-box {
            position: absolute;
            width: 4.266667rem;
            height: 4.5rem;
            top: 50%;
            left: 50%;
            margin-left: -2.133333rem;
            margin-top: -2.6rem;
            margin-bottom: .5rem;
            background-color: #fff;
            border-radius: 10px;
            padding-top: 0.333333rem;
            box-sizing: border-box;
            position: relative;
        }

        #guize .weui-popup__modal .guize-box .guize-box_hd {
            text-align: center;
            font-size: 0.24rem;
            color: #282c37;
            font-weight: 500;
            margin-bottom: 0.266667rem;
        }

        #guize .weui-popup__modal .guize-box .guize-box_bd {
            padding-left: 0.333333rem;
            padding-right: 0.333333rem;
        }

        #guize .weui-popup__modal .guize-box .guize-box_bd li {
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: start;
            -webkit-justify-content: flex-start;
            justify-content: flex-start;
            -webkit-box-align: baseline;
            -webkit-align-items: baseline;
            align-items: baseline;
            margin-bottom: 0.2rem;
        }

        #guize .weui-popup__modal .guize-box .guize-box_bd li .num {
            width: 0.2rem;
            height: 0.2rem;
            background-color: #ea9c3b;
            border-radius: 50%;
            color: #ffffff;
            text-align: center;
            line-height: 0.133333rem;
            margin-right: 0.066667rem;
            line-height: 0.2rem;
            font-size: 0.173333rem;
        }

        #guize .weui-popup__modal .guize-box .guize-box_bd li .text {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            line-height: 0.293333rem;
            letter-spacing: 0;
            color: #282c37;
        }

        #guize .weui-popup__modal .guize-box .guize-box_ft {
            position: absolute;
            bottom: -0.766667rem;
            text-align: center;
            width: 100%;
        }

        #guize .weui-popup__modal .guize-box .guize-box_ft img {
            width: 0.466667rem;
        }

    </style>
</head>
<body>
<div class="page">
    <div class="page-hd">
        <div class="header">
    <div class="header-left">
        <a href="javascript:history.go(-1)" class="left-arrow"></a>
    </div>
    <div class="header-title">注册</div>
    <div class="header-right">
        <div class="right_menu">

        </div>
    </div>
</div>
    </div>
    <div class="page-bd" >
        <!-- 页面内容-->
        <div class="weui-cells bg-fff" >
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">推荐码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" name="invitecode" value="{$invitecode}" placeholder="请输入推荐码" type="text">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">账号</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" name="account"  maxlength="20" placeholder="请输入账号" type="text">
                </div>
            </div>
            <!--<div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">输入姓名</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="输入姓名"  name="nickname"  type="text">
                </div>
            </div>-->
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">登录密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="设置密码 （6-16个字符,需含数字、字母）" type="password" name="password">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">确认密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="再次输入密码" name="relogin_pwd"  type="password">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">邮箱</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="请输入邮箱" name="email"  type="text">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">验证码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="请输入验证码" name="email_code"  type="text" style="width: 50%">
                    <a href="javascript:void(0)" id="send" onclick="sendCode()" style="background: #F00;color: #fff;padding: 6px;border-radius: 20px;">获取验证码</a>
                </div>
            </div>
            <!--<div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">二级密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input"placeholder="设置二级密码 （6-16个字符,需含数字、字母）" type="password" name="paypassword">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">确认密码</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input phone_input" placeholder="再次输入二级密码" name="relogin_paypasspwd"  type="password">
                </div>
            </div>-->
        </div>
        <div class="weui-agree pt40 pb0">
            <input id="weuiAgree" type="checkbox" name="agree" class="weui-agree__checkbox">
            <span class="weui-agree__text">
                我已详细阅读并同意
                <a href="javascript:void(0);" class="color1 open-popup" data-target="#guize">服务条款</a>
            </span>
        </div>
        <div class="weui-btn-area">
            <input class="weui-input" maxlength="6" id="yzm_input" onInput ="returnNum(this)" name="code" value="1" placeholder="输入验证码" type="hidden">
            <a href="javascript:void(0)" onclick="reg()" style="background-image: linear-gradient(250deg, #e62e2e 0%, #e62e2e 100%), linear-gradient(#e62e2e, #e62e2e) !important;
    box-shadow: 0.033333rem 0.058rem 0.133333rem 0 rgba(157, 157, 157, 0.3);
}"  class="weui-btn weui-btn_primary bg-danger">立即注册</a>
        </div>
        <div class="fixed_style1">
            <!-- <a href="首页.html" class="weui-btn weui-btn_plain-primary weui-btn_class1">首页</a> -->
        </div>

    </div>
</div>
<div id="guize" class="weui-popup__container alert_box">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal guize-box">
        <div class="guize-box weui-popup__modal_box" style="background-image: url('__PUBLIC__/assets_reg/images/dc_alert.png')">
            <div class="guize-box_hd">
                注册协议
            </div>
            <div class="guize-box_bd">
                <ul style="height: 3rem;overflow: auto;">
                    <li>
                        <span class="num" style="background-color: #9752de;">1</span>
                        <p class="text">
                            尊敬的用户请认真阅读以下规则
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">2</span>
                        <p class="text">
                            年龄范围18至70周岁，不用上传手持照片，注册账号必须为本人银行卡绑定手机号码，平台将在2天内审核完毕。
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">3</span>
                        <p class="text">
                            平台为保证每位用户资金安全，用户真实姓名与支付宝不一致将永久封号处理。
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">4</span>
                        <p class="text">
                            如果用户出现违规情况平台将会立即冻结账号，永不解封，切相关人员有连带责任
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">5</span>
                        <p class="text">
                            所有规则请严格遵照制度执行，任何一方违规将被系统冻结账号。
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">6</span>
                        <p class="text">
                            平台不会无故封杀账号，同时也不会放过任何一个恶意注册的人员
                        </p>
                    </li>
                    <li>
                        <span class="num" style="background-color: #9752de;">7</span>
                        <p class="text">
                            平台每日会开启自动检测系统，恶意刷号将会连带封杀。
                        </p>
                    </li>

                </ul>
            </div>
            <div class="guize-box_ft">
                <img src="__PUBLIC__/assets_reg/images/icon_del1.png" alt="" class="close-popup">
            </div>
        </div>

    </div>
</div>

<script src="__PUBLIC__/assets_reg/js/lib/jquery-2.1.4.js"></script>
<script src="__PUBLIC__/assets_reg/js/jquery-weui.min.js"></script>
<script src="__PUBLIC__/assets_reg/js/jquery.cookie.js"></script>

<script>
$.toast.prototype.defaults.duration = 1500;
    function returnNum(_this) {
        _this.value = _this.value.replace(/[^0-9]/g, '');
    }

    //发送验证码时添加cookie
    function addCookie(name,value,expiresHours){
        //判断是否设置过期时间,0代表关闭浏览器时失效
        if(expiresHours>0){
            var date=new Date();
            date.setTime(date.getTime()+expiresHours*1000);
            $.cookie(name, escape(value), {expires: date});
        }else{
            $.cookie(name, escape(value));
        }
    }
    //修改cookie的值
    function editCookie(name,value,expiresHours){
        if(expiresHours>0){
            var date=new Date();
            date.setTime(date.getTime()+expiresHours*1000); //单位是毫秒
            $.cookie(name, escape(value), {expires: date});
        } else{
            $.cookie(name, escape(value));
        }
    }
    //根据名字获取cookie的值
    function getCookieValue(name){
        return $.cookie(name);
    }
    //加载页面时获取Cookie并判断
    $(document).ready(function(){
        var obj1 = $("#send");
        v = getCookieValue("secondsremained");//获取cookie值
        if(v>0){
            settime(obj1);//开始倒计时
        }
    });
    //定义倒计时变量
    var countdown;

    // 倒计时函数
    function settime(obj) { //发送验证码倒计时
        countdown=getCookieValue("secondsremained");
        if (countdown === "0") {
            obj.attr('disabled',false);
            //obj.removeattr("disabled");
            obj.text("获取验证码");
            obj.css("background","#f00");
            return;
        } else {
            obj.attr('disabled',true);
            obj.text("重新发送(" + countdown + ")");
            obj.css("background","#999");
            countdown--;
            editCookie("secondsremained",countdown,countdown+2);
        }
        setTimeout(function() {
                settime(obj) }
            ,1000)
    }

    //发送验证码
    function sendCode() {
        var mail = $("input[name='email']").val();
        var myreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        if(!myreg.test(mail)){
            $.toast("请输入正确的邮箱！", "cancel");
            return false;
        }
        v = getCookieValue("secondsremained");//获取cookie值
        if (v == null || v < 0) {
            var obj = $("#send");
            addCookie("secondsremained", 60, 60);//添加cookie记录,有效时间60s
            settime(obj);//开始倒计时
            $.ajax({
                method: 'POST',
                dataType: 'JSON',
                data: {
                    "email" : mail
                },
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                url: "{:U('Login/sendEmailCode')}",
                success: function (data) {
                    $.toast(data.msg, "success");
                },error: function (result) {
                    $.toast('请求错误', "cancel");

                }
            });
        }
    }


    var load_app_link="{$poster.poster_link}";
    reg = function () {
        if ($("input[name='password']").val() !== $("input[name='relogin_pwd']").val() ) {
            $.toast("两次密码不一致", "cancel");
            return false;
        }
        /*if ($("input[name='paypassword']").val() !== $("input[name='relogin_paypasspwd']").val() ) {
            $.toast("两次二级密码不一致", "cancel");
            return false;
        }*/
        var regAccount = /^[0-9a-zA-Z]*$/g;
        var account = $("input[name='account']").val();
        if (!regAccount.test(account)){
            $.toast("账号只能用数字或字母", "cancel");
            return false;
        }
        var agree = $("input[name='agree']").is(':checked');
        if (agree == false) {
            $.toast("需同意注册条款方可注册", "cancel");
            return false;
        }
        $.ajax({
            method: 'POST',
            dataType: 'JSON',
            data: {
                "agree" : agree,
                "nickname" : $("input[name='nickname']").val(),
                "invitecode" : $("input[name='invitecode']").val(),
                "account" : $("input[name='account']").val(),
                "code" : $("input[name='code']").val(),
                "password" : $("input[name='password']").val(),
                // "paypassword" : $("input[name='paypassword']").val()
            },
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            url: "{:U('Login/validaform')}",
            success: function (data) {
                if(data.code==-1){
                    $.toast(data.msg, "cancel");

                }else if(data.code==0){
                    setTimeout(function () {
                        gotoreg();
                    },100)
                }
            },error: function (result) {
                $.toast('请求错误', "cancel");

            }
        });
    }
    gotoreg = function () {
        $.ajax({
            method: 'POST',
            dataType: 'JSON',
            data: {
                "nickname" : $("input[name='nickname']").val(),
                "invitecode" : $("input[name='invitecode']").val(),
                "account" : $("input[name='account']").val(),
                "emailcode" : $("input[name='email_code']").val(),
                "password" : $("input[name='password']").val(),
                "mail" : $("input[name='email']").val(),
                // "paypassword" : $("input[name='paypassword']").val(),
            },
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            url: "{:U('Login/register')}",
            success: function (data) {
                if(data.code==-1){
                    $.toast(data.msg, "cancel");
                }
                else if(data.code==0){
                    $.toast("注册成功");
                    setTimeout(function () {
                        // window.location.href="/index.php/Vpay/Login/login"
                        var act = {$act};
                        if (act == 1) {
                            /*if(load_app_link){
                                window.location.href = load_app_link;
                            }else{
                                window.location.href = "{:U('Login/app_download')}"
                            }*/
                            window.location.href = 'http://d.firim.vip/s2t3';

                        }else{
                            // window.location.href = "{:U('Login/login')}"
                            window.location.href = 'http://d.firim.vip/s2t3';
                        }
                    },1500)
                }
        },error: function (result) {
                $.toast("请求错误！", "cancel");
            }
        });
    }
</script>
</body>
</html>
